<template>
  <div class="avatar" :class="avatarCls">
    <router-link
      :to="{ name: 'account', params: { uuid: this.uuid } }"
      target="_blank"
      v-if="this.uuid !== '0'"
    >
      <el-image :src="url" fit="cover" class="img" lazy>
        <div slot="error" style="width: 100%; height: 100%">
          <SvgIcon
            iconClass="default-avatar"
            style="width: 100%; height: 100%"
          ></SvgIcon>
        </div>
      </el-image>
    </router-link>
    <SvgIcon
            iconClass="default-avatar"
            class="img"
          v-else></SvgIcon>
  </div>
</template>

<script>
export default {
  props: {
    url: {
      type: String,
      default: '',
    },
    // 尺寸 可选 sm、 md、 lg
    size: {
      type: String,
      default: "sm",
    },
    // 跳转参数
    uuid: {
      type: String,
      default: '0',
    },
  },
  computed: {
    avatarCls() {
      return this.size ? `avatar-${this.size}` : "";
    },
  },
};
</script>

<style lang="scss" scoped>
.avatar {
  background-color: #f6f6f7;
  // cursor: pointer;
  .img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
  }
}
.avatar-sm {
  width: 36px;
  height: 36px;
}
.avatar-md {
  width: 54px;
  height: 54px;
}

.avatar-lg {
  width: 72px;
  height: 72px;
}
</style>